<template>
	<view>
		<view class="my-box">
			<view class="top">
				<image :src="userInfo.avatarUrl" mode=""></image>
				<text>{{userInfo.nickName}}</text>
			</view>
			<view class="bottom">
				<view class="bottom-top">
					<view class="bottom-top-item">
						<text>8</text>
						<text>收藏的店铺</text>
					</view>
					<view class="bottom-top-item">
						<text>14</text>
						<text>收藏的商品</text>
					</view>
					<view class="bottom-top-item">
						<text>18</text>
						<text>关注的商品</text>
					</view>
					<view class="bottom-top-item">
						<text>84</text>
						<text>足迹</text>
					</view>
				</view>
				
				<view class="bottom-center">
					<view class="dingdan">我的订单</view>
					<view class="bottom-center-box">
						<view class="bottom-center-item">
							<image src="/static/my-icons/icon1.png" mode=""></image>
							<text>待付款</text>
						</view>
						<view class="bottom-center-item">
							<image src="/static/my-icons/icon2.png" mode=""></image>
							<text>待收货</text>
						</view>
						<view class="bottom-center-item">
							<image src="/static/my-icons/icon3.png" mode=""></image>
							<text>退款/退货</text>
						</view>
						<view class="bottom-center-item">
							<image src="/static/my-icons/icon4.png" mode=""></image>
							<text>全部订单</text>
						</view>
					</view>
				</view>
				
				<view class="bottom-bottom">
					<view class="bottom-bottom-item">
						<text>收货地址</text>
						<uni-icons type="right" size="20"></uni-icons>
					</view>
					<view class="bottom-bottom-item">
						<text>联系客服</text>
						<uni-icons type="right" size="20"></uni-icons>
					</view>
					<view class="bottom-bottom-item">
						<text @click='loginExit'>退出登录</text>
						<uni-icons type="right" size="20"></uni-icons>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {mapState,mapMutations} from 'vuex';
	export default {
		name:"my_userInfo",
		data() {
			return {
				
			};
		},
		computed:{
			...mapState('user_m',['userInfo'])
		},
		methods:{
			...mapMutations('user_m',['updateToken','updateUserInfo','updateAddress']),
			//退出登录  token userInfo address 都要删除或者赋值为空
			async loginExit(){
				console.log('退出登录');
				//退出登录的提示框  返回的是数组
				//解构 err在前 succ在后
				const [err,succ] = await uni.showModal({
					title:'提示',
					content:'是否确认退出登录？'
				}).catch(err=>err);
				//内部有 confirm 确认   cancel 取消
				console.log(err,succ);
				if(succ && succ.confirm){
					this.updateToken('');
					this.updateUserInfo({});
					this.updateAddress({});
				}
			}
		}
	}
</script>

<style lang="scss">
.my-box{
	width: 100%;
	height: 100vh;
	background-color: #F4F4F4;
	.top{
		width: 100%;
		height: 190px;
		background-color: #c00000;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
		image{
			width: 100px;
			height: 100px;
			border-radius: 50%;
			border: 2px solid #ffffff;
		}
		text{
			color: white;
			margin-top: 5px;
		}
	}
	.bottom{
		margin: 0 10px;
		position: relative;
		top:-10px;
		.bottom-top{
			height: 55px;
			border-radius: 5px;
			display: flex;
			justify-content: space-around;
			align-items: center;
			background-color: #ffffff;
			.bottom-top-item{
				display: flex;
				flex-direction: column;
				align-items: center;
				font-size: 26rpx;
			}
		}
		.bottom-center{
			font-size: 26rpx;
			height: 120px;
			background-color: #ffffff;
			margin-top: 8px;
			border-radius: 5px;
			.dingdan{
				line-height: 40px;
				padding-left: 10px;
				font-size: 30rpx;
			}
			.bottom-center-box{
				display: flex;
				justify-content: space-around;
				align-items: center;
				
				.bottom-center-item{
					height: 80px;
					display: flex;
					align-items: center;
					flex-direction: column;
					justify-content: center;
					image{
						width: 40px;
						height: 40px;
					}
				}
			}
		}
		.bottom-bottom{
			height: 135px;
			background-color: #ffffff;
			margin-top: 8px;
			display: flex;
			flex-direction: column;
			justify-content: space-around;
			border-radius: 5px;
			.bottom-bottom-item{
				padding: 0 10px;
				display: flex;
				justify-content: space-between;
			}
		}
	}
}
</style>
